package com.augn.controller;

import com.augn.entity.Result;
import com.augn.entity.User;
import com.augn.service.IUserService;
import com.augn.utils.RedisUtil;
import com.augn.utils.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author augn
 * @since 2022-09-22
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService service;

    @PostMapping("/insertOne")
    public Result<?> insertOneUser(@RequestBody User user){
        return service.insertOneUser(user);
    }

    @DeleteMapping("/deleteOne/{id}")
    public Result<?> deleteOneUser(@PathVariable Integer id){
        return service.deleteOneUser(id);
    }

    @PutMapping("/updateOne")
    public Result<?> updateOneUser(@RequestBody User user){
        return service.updateOneUser(user);
    }

    @GetMapping("/getOne/{id}")
    public Result<?> getOneUser(@PathVariable Integer id){
        return service.getOneUser(id);
    }

    @PostMapping("/getPart")
    public Result<?> getPartUser(@RequestBody User user,
                                 @RequestParam(required = false) Integer pageNum,
                                 @RequestParam(required = false) Integer pageSize){
        return service.getPartUser(user,pageNum,pageSize);
    }

    @PostMapping("/login")
    public Result<?> UserLogin(@RequestBody User user){
        return service.login(user);
    }
}
